package 美团笔试;

import java.util.Scanner;

/**
 @author fujiangnan
 @create 2021-09-25-15-33
 @desc 美团笔试
 */
public class Main {
    public static String flag = "NO";
    public static Integer sum = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int len = sc.nextInt();
        String[] ans = new String[len];
        for (int i = 0; i < len; i++) {
            int[] arr = new int[sc.nextInt()];
            int n = sc.nextInt();
            int target = sc.nextInt();
            for (int j = 0; j < arr.length; j++) {
                arr[j] = sc.nextInt();
                sum += arr[j];
            }
            sumByN(arr, 0, n, target);
            ans[i] = flag;
            flag = "NO";
            sum = 0;
        }
        for (int i = 0; i < len; i++) {
            System.out.println(ans[i]);
        }

    }
    public static void sumByN(int[] arr, int start, int n, int target) {
        if (sum == target) {
            flag = "YES";
            return;
        }
        for (int i = start; i < n; i++) {
            sum += (arr[i]*arr[i]*arr[i]);
            sumByN(arr, start+1, n, target);
            sum -= (arr[i]*arr[i]*arr[i]);
        }
    }
}
